﻿<?php include("conn.php");
mysql_query('SET NAMES UTF8'); 



class MyPrizeBean
{
	public $zongjia;

	function __construct($zongjia)
	{
		$this->zongjia    = $zongjia;
	}
}

if($_POST["sid"]!="")
{
	$de=$_POST["sid"]*30;
}
else
{
	$de=0;
}




if($_REQUEST[shopid]!="")
{
	$state2=2;
	$rert36=mysql_query("select *from car where userid='".$_REQUEST[userid]."' and state !='".$state2."' and shopid ='".$_REQUEST[shopid]."' order by carid desc");

	while($rowf6=mysql_fetch_array($rert36)){

		$rert32=mysql_query("select *from car where  carid ='".$rowf6[carid]."'");
		$rowf2=mysql_fetch_array($rert32);
		if($_REQUEST[d]==1)
		{
			$states=3;
		}
		else
		{
			$states=0;
		}
		$srat=mysql_query("update car set state='".$states."' where carid='".$rowf6[carid]."'");
	}
}else{
	$rert32=mysql_query("select *from car where  carid ='".$_REQUEST[carid]."'");
	$rowf2=mysql_fetch_array($rert32);
	if($_REQUEST[d]==1)
	{
		$states=3;
	}
	else
	{
		$states=0;
	}
	$srat=mysql_query("update car set state='".$states."' where carid='".$_REQUEST[carid]."'");
}
$prize = array();
$zongj=0;
$state=3;
$rert30=mysql_query("select *from car where userid='".$_REQUEST[userid]."' and state='".$state."' ");

while($rowf=mysql_fetch_array($rert30)){

	$zongj=$zongj+$rowf[price]*$rowf[number];

}

$prize[] = new MyPrizeBean($zongj);



echo json_encode($prize);


?>